package com.coincalf.service;

import com.alicp.jetcache.anno.CacheType;
import com.alicp.jetcache.anno.Cached;
import com.baomidou.mybatisplus.service.IService;
import com.coincalf.dto.AgentRegisterDTO;
import com.coincalf.entity.User;
import com.coincalf.framework.constants.Constant;
import com.coincalf.framework.http.Response;
import com.coincalf.framework.security.UserDetails;
import com.coincalf.web.vo.*;

import java.util.List;

/**
 * <p>
 * 用户表 服务类
 * </p>
 *
 * @author qiang
 * @since 2018-05-12
 */
public interface UserService extends IService<User> {

    /**
     * 根据用户名查询用户
     *
     * @param username 用户名
     * @return
     */
    User selectByUsername(String username);

    /**
     * 根据手机号查询用户是否已注册
     *
     * @param mobile 手机号
     * @return
     */
    User selectByMobile(String mobile);

    /**
     * 用户注册
     *
     * @param form 注册信息
     * @return
     */
    Response register(RegisterForm form);

    /**
     * 实名认证
     */
    Response updateAuthAccount(UserDetails userDetails, UserAuthInfoForm form);

    /**
     * 修改资金密码
     */
    Response updatePayPassword(User user, ChangePasswordForm form);

    /**
     * 修改登录密码
     */
    Response updatePassword(UserDetails userDetails, ChangePasswordForm form);

    /**
     * 修改手机号
     */
    Response updatePhone(UserDetails userDetails, ChangePhoneForm form);

    /**
     * 设置资金密码
     */
    Response setPayPassword(User user, ChangePayPasswordForm form);

    /**
     * 设置密码
     *
     * @param form
     * @return
     */
    Response setPassword(SetPasswordForm form);

    /**
     * 高级实名认证
     *
     * @param userDetails
     * @param forms
     * @return
     */
    Response authUser(UserDetails userDetails, List<String> forms);

    /**
     * 设置用户基本信息
     *
     * @param userDetails
     * @param form
     * @return
     */
    Response setUserBase(UserDetails userDetails, UserBaseForm form);

    /**
     * 查询邀请列表
     *
     * @param userId 用户ID
     * @return
     */
    List<User> selectListByInviteId(long userId);

    /**
     * 代理商注册
     *
     * @param agentRegister 代理商注册信息
     * @return
     */
    Response agentRegister(AgentRegisterDTO agentRegister);

    /**
     * 查询代理商邀请的用户列表
     *
     * @param userId 用户ID
     * @return
     */
    List<User> selectAgentInvitation(Long userId);

    /**
     * 查询管理员用户
     *
     * @param userName
     * @return
     */
    @Cached(name = Constant.CACHE_KEY_ADMIN_USER, cacheType = CacheType.LOCAL)
    User queryAdminUser(String userName);

    public Object registerForPhp(String token);

    public User selectByPhone(String phone);

}
